
/**
 * Created by seeker910 on 2014/8/28.
 * @description 组件名称命名约定：继承container组件，名称以ViewPart结尾;继承control组件，名称以Part结尾
 * scroll top
 */
Rsd.define('Rsd.hermit.sections.ScrollTopPart', {
    extend: 'Rsd.control.Svg',
    requires: [
        'Rsd.form.Image',
        'Rsd.form.Text',
        'Rsd.form.Button'
    ],
    xtype: 'scroll-top',
    domEditable:false,
     /**
     * @description true:表示只允许在模板中修改
     */
    editInMaster:false,
    label: false,
    floating: true,
    fixed: true,
    width: '30px',
    height: '30px',
    hidden:true,
    style: { 
        padding: '10px',
        backgroundColor: '#5e006fc7',
        zIndex: 999,
        borderRadius: '40px',
        bottom: '100px',
        right: '100px'
    },
    dataSource: {
        viewBox: "0 0 1024 1024",
        path: "M476.55036397 485.73640755L51.8175352 910.47959262c-19.78442841 20.29447648-19.57600773 52.72395472 0.46603378 72.76340717 20.04204151 20.03945245 52.47151977 20.24269495 72.76340718 0.45567746l388.12328643-388.10257382 388.11293012 388.12328644a51.78411995 51.78411995 0 1 0 73.23979727-73.22944094L549.77980492 485.73640755c-20.22068781-20.21421511-52.99839683-20.21421511-73.21908465 0l-0.0103563 0z m0-445.32116544L51.81753519 465.15842718c-19.78442841 20.29447648-19.57600773 52.72395472 0.46603379 72.76340717 20.04204151 20.03945245 52.47151977 20.24269495 72.76340718 0.45567747l388.12328643-388.10257384 388.11293014 388.12328646a51.78411995 51.78411995 0 1 0 73.23979724-73.22944095L549.77980492 40.41524211c-20.22068781-20.21421511-52.99839683-20.21421511-73.21908465 0l-0.0103563 0z",
        fill: "#ffffff"
    },
   
    /**
     * 
     * @param {*} config 
     */
    constructor: function ScrollTopPart(config) {
        config = config || {};
        Rsd.apply(this, config);
    },
    /**
     * 
     */
    onAfterInit:function onAfterInit()
    {
        this.callParent();
        var me = this; 
         
        window.addEventListener('scroll', function () {

            var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
            var clientHeight = document.documentElement.clientHeight || window.innerHeight;
            if (scrollTop > clientHeight/3) 
            {
                me.show(); 
            } 
            else 
            {
               me.hide();
            }

        }); 
        
    },
    /**
     * 
     * @returns 
     */
    handler:function handler()
    {
        window.scrollTo(0,0);
        return false;
    }

});



